package com.sl.biz.modular.office.dao.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.office.dao.domain.entity.OfficeRecordContentDO;
import com.sl.biz.modular.office.dao.mapper.OfficeRecordContentMapper;
import com.sl.biz.modular.office.dao.service.OfficeRecordContentDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class OfficeRecordContentDaoServiceImpl extends ServiceImpl<OfficeRecordContentMapper, OfficeRecordContentDO> implements OfficeRecordContentDaoService {
    @Override
    public Boolean removeByOfficeId(String officeId) {
        LambdaQueryWrapper<OfficeRecordContentDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(OfficeRecordContentDO::getOfficeId, officeId);
        return super.remove(lambdaQueryWrapper);
    }

    @Override
    public OfficeRecordContentDO getByOfficeId(String officeId) {
        LambdaQueryWrapper<OfficeRecordContentDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(OfficeRecordContentDO::getOfficeId, officeId);
        return CollUtil.get(super.list(lambdaQueryWrapper), 0);
    }
}
